/*
题目链接:https://leetcode.cn/problems/count-symmetric-integers/solutions/?envType=daily-question&envId=2025-04-11
*/

//题解代码:

class Solution {
public:
    int countSymmetricIntegers(int low, int high) {
        int ans = 0;
        for(int x = low; x<=high; ++x){
            string num = to_string(x);
            int n = num.size();
            if((n&1)==0){
                int pre = 0, suf = 0;
                for(int i=0;i<n/2;++i){
                    pre += num[i];
                    suf += num[n-1-i];
                }
                ans += pre == suf;
            }

        }
        return ans;
    }
};
